package com.example.springboot_jdk8.api;

import com.example.springboot_jdk8.util.TestSpringEl;
import com.example.subbeancontext.TestBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/test")
public class TestApi {

    @Autowired
    private TestBean testBean;

    @PostMapping("/hello")
    public void testPost( @RequestParam(required = false) String appId){
        System.out.println(appId);
    }


    @GetMapping("/helloGet")
    public String testGet( @RequestParam(required = false) String appId){
        System.out.println(appId);
        String elStr = TestSpringEl.getElStr("hello.test");
        System.out.println(elStr);
        return appId;
    }

    @GetMapping("/reloadMethod")
    public void reloadMethod(@RequestParam Integer num){
        System.out.println("retransform method after reload 222: "+num);
        if (num % 2 == 0) {
            testBean.print();
        } else {
            testBean.print(num + "");
        }
    }
}
